#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int checkAdventurer(int p, struct gameState *state) {

	printf("Testing Adventurer\n");
	int r, discardCount, handCount, deckCount, newDiscardCount, newHandCount, newDeckCount;
	discardCount = state->discardCount[p];
	deckCount = state->deckCount[p];
	handCount = state->handCount[p];

	printf("Calling Adventurer function\n");
	r = zzzadventurercardplay(0, p, 0,0, 0, state);
	assert(r == 0);
	printf("lolz");

	newDeckCount = state->deckCount[p];;
	newDiscardCount = state->discardCount[p];
	newHandCount = state->handCount[p];

	assert(newDeckCount + newDiscardCount == (deckCount + discardCount) - 2);
	assert(newHandCount == handCount + 2);

	return 0;
}

int main() {

	int r, p, deckCount, discardCount, handCount;
	int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

	struct gameState G;

	for (p = 0; p < 2; p++) {
		for (deckCount = 0; deckCount < 10; deckCount++) {
			for (discardCount = 0; discardCount < 10; discardCount++) {	
				for (handCount = 0; handCount < 10; handCount++) {	
					memset(&G, 23, sizeof(struct gameState));
					printf("Initializing test game\n");
					r = initializeGame(2, k, 1, &G);
					G.deckCount[p] = deckCount;
					memset(G.deck[p], 0, sizeof(int) * deckCount);
					G.discardCount[p] = discardCount;
					memset(G.discard[p], 0, sizeof(int) * discardCount);
					G.handCount[p] = handCount;
					memset(G.hand[p], 0, sizeof(int) * handCount);
					checkAdventurer(p, &G);
				}
			}
		}
	}

}
